# 220203 1044
# 创建数组

# numpy.empty
# numpy.empty(shape, dtype = float, order = 'C')

import numpy as np

x9 = np.empty([3,2], dtype=int)
print('x9=', x9)

x12 = np.empty([3,2], dtype=int, order='F')
print('x12=', x12)

print('end.1')

# numpy.zeros
# 数组元素以 0 来填充
# numpy.zeros(shape, dtype = float, order = 'C')

x20 = np.zeros(4);
print('x20=', x20)

x23 = np.zeros([2,3], dtype=int)
print('x23=', x23)

# 自定义类型
x27 = np.zeros((2,2), dtype=[('x', 'i4'), ('y', 'i4')])
print('x27=', x27)

print('end.2')

# numpy.ones(shape, dtype = None, order = 'C')
# 数组元素以 1 来填充

x36 = np.ones([3,4])
print('x36=', x36)

x39 = np.ones([3,4], dtype=int)
print('x39=', x39)

print('end.3')

# 创建标准正态分布数组

from numpy import *

# 创建 randn(size) 服从 X~N(0,1) 的正态分布随机数组
x45 = random.randn(2,3)
print('x45=', x45)

# 创建随机分布整数型数组
# randint([low,high],size)

x54 = random.randint(100, 200, (3,3))
print('x54=', x54)

# arange 创建数组

print('np.arange:')
print(np.arange(10)) # [0 1 2 3 4 5 6 7 8 9]
print(np.arange(10,20)) # [10 11 12 13 14 15 16 17 18 19]
print(np.arange(10, 20, 2))

# eye 创建对角矩阵数组

print(np.eye(5))

# order 中的 C 应该是从低维度开始读写，而 F 顺序则是从高维度开始读写

x71 = np.array([[[1, 2],[3, 4],[5,6]],[[7, 8],[9,10],[11,12]]])
print('x71=', x71)
print(x71.shape)

print(np.reshape(x71, (4,3))) # 默认 order 为 C

print(np.reshape(x71, (4,3), order='F')) # 有些看不懂了

print('end.4')